home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.4d7 source
/
tn3270
/
dialogs.c
< prev
next >
Wrap
Text File
|
1992-04-17
|
65KB
|
2,822 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.4d7 April, 1992
* Copyright (c) 1988, 1989, 1990, 1991, 1992 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistants Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#pragma segment 3270seg3
#if !defined(USEDUMP)
#include "maclib.h"
#include "termdef.h"
#include "tn3270funcs.h"
#include "globals.h"
#else
#pragma load "tn3270DumpFile"
#endif
#include <Lists.h>
#define kButtonFrameSize 3 /* button frame's pen size */
#define kButtonFrameInset -4 /* inset rectangle adjustment around button */
extern char showstg;
extern char notifyavail;
extern nmrmessage *myNMR[NMRNUM];
extern struct Point sfgpoint;
unsigned char * dlgmapptr;
short attnmousepf; /* for attndlg */
extern unsigned char setmsg1[];
extern unsigned char setmsg2[];
extern unsigned char setmsg3[];
static short fmtmaxrows, fmtmaxcols;
void aboutdlg(void)
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short * itemHitPtr;
short itemHit;
Handle version;
short gtype;
Handle gitem;
Rect gbox;
static unsigned short * DlgFont = (unsigned short *)0xAFA;
version = GetResource('GFTM', 0);
dStorage = 0;
behind = (WindowPtr)-1;
*DlgFont = 1;
dlgptr = GetNewDialog(256, dStorage, behind);
ctrwindow(dlgptr);
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
SetIText(gitem, *version);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ModalDialog(filterProc, itemHitPtr);
if (itemHit == 2) showstg = 1;
DisposDialog(dlgptr);
*DlgFont = 0;
}
void stginfo(cnr *cp) /* display storage info. */
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short * itemHitPtr;
short itemHit;
short gtype;
Handle gitem;
Rect gbox, r;
unsigned char msg[120];
GDHandle currGD;
PixMapHandle currPM;
short i, j;
long l;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(270, dStorage, behind);
ctrwindow(dlgptr);
/* define info. text */
if (cp != 0) {
if (cp->myWindow != 0) {
if (colormac && (!cp->cs.nocolor)) {
GetGlobalRect(cp->myWindow, &r);
currGD = myGetMaxDevice(&r);
currPM = (*currGD)->gdPMap;
i = (*currPM)->pixelSize;
j = 2 << (i-1);
sprintf(msg, "pixel depth = %d (%d colors)", i, j);
}
else {
sprintf(msg, "pixel depth = 1 (black & white)");
}
}
}
else {
if (colormac && (!cf_nocolor)) {
currGD = GetMainDevice();
currPM = (*currGD)->gdPMap;
i = (*currPM)->pixelSize;
j = 2 << (i-1);
sprintf(msg, "pixel depth = %d (%d colors)", i, j);
}
else {
sprintf(msg, "pixel depth = 1 (black & white)");
}
}
GetDItem(dlgptr, 2, >ype, &gitem, &gbox);
c2pstr(msg);
SetIText(gitem, msg);
if (cp != 0) {
if (cp->myWindow != 0) {
i = (cp->textsize+1023) >> 10;
if (cp->mapptr == 0) {
sprintf(msg, "no text bitmap (needs %dK)", i);
i = 0;
}
else {
sprintf(msg, "text bitmap = %dK", i);
}
}
}
else {
i = 0;
sprintf(msg, "no text bitmap (no session)");
}
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
c2pstr(msg);
SetIText(gitem, msg);
if (cp != 0) {
if (cp->myWindow != 0) {
j = (cp->pictsize+1023) >> 10;
if (cp->pmapptr == 0) {
if (j == 0) {
sprintf(msg, "no graphics bitmap (disabled)");
}
else {
sprintf(msg, "no graphics bitmap (needs %dK)", j);
j = 0;
}
}
else {
sprintf(msg, "graphics bitmap = %dK", j);
}
}
}
else {
j = 0;
sprintf(msg, "no graphics bitmap (no session)");
}
GetDItem(dlgptr, 4, >ype, &gitem, &gbox);
c2pstr(msg);
SetIText(gitem, msg);
sprintf(msg, "bitmap total = %dK", i+j);
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
c2pstr(msg);
SetIText(gitem, msg);
MaxApplZone();
l = FreeMem() >> 10;
sprintf(msg, "available storage = %ldK", l);
GetDItem(dlgptr, 6, >ype, &gitem, &gbox);
c2pstr(msg);
SetIText(gitem, msg);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* show the text */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ModalDialog(filterProc, itemHitPtr);
DisposDialog(dlgptr);
}
void attrdlg(cnr *cp)
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short itemHit;
short gtype;
Handle gitem;
Rect gbox;
unsigned char tempmap[35];
register short i, j;
register unsigned char c;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(257, dStorage, behind);
ctrwindow(dlgptr);
/* handle attribute selection dialog */
filterProc = DlgFilter;
j = 0;
for (i=0; i<7; i++) {
c = cp->cs.attrmap[i] >> 3;
tempmap[j++] = (c & 0x10) >> 4;
tempmap[j++] = (c & 0x08) >> 3;
tempmap[j++] = (c & 0x04) >> 2;
tempmap[j++] = (c & 0x02) >> 1;
tempmap[j++] = c & 0x01;
}
for (i=0; i < 35; i++) {
GetDItem(dlgptr, i+18, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, tempmap[i]);
}
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
ModalDialog(filterProc, &itemHit);
while ((itemHit != 1) && (itemHit != 3)) {
if (itemHit == 2) { /* set defaults */
j = 0;
for (i=0; i<7; i++) {
c = ds.attrmap[i] >> 3;
tempmap[j++] = (c & 0x10) >> 4;
tempmap[j++] = (c & 0x08) >> 3;
tempmap[j++] = (c & 0x04) >> 2;
tempmap[j++] = (c & 0x02) >> 1;
tempmap[j++] = c & 0x01;
}
for (i=0; i < 35; i++) {
GetDItem(dlgptr, i+18, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, tempmap[i]);
}
}
else {
i = itemHit - 18;
tempmap[i] ^= 1;
GetDItem(dlgptr, itemHit, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, tempmap[i]);
}
ModalDialog(filterProc, &itemHit);
}
if (itemHit == 1) {
j = 0;
for (i=0; i<7; i++) {
c = (tempmap[j]<<4) + (tempmap[j+1]<<3) + (tempmap[j+2]<<2) +
(tempmap[j+3]<<1) + tempmap[j+4];
j += 5;
c <<= 3;
cp->cs.attrmap[i] = c;
}
if (cp->myWindow != 0) invldscr(cp);
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
void hostcfdlg(void)
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short itemHit;
short gtype;
Handle gitem;
Rect gbox;
unsigned char dflthostname[256];
char savedefault;
short i;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(262, dStorage, behind);
ctrwindow(dlgptr);
savedefault = 0;
/* show current values of items */
sethostcf(dlgptr, cf_hostname, cf_wtitle, savedefault);
/* select host name text */
SelIText(dlgptr, 5, 0, 32767);
/* Make Default is only for TCP */
setactive(8, dlgptr, cf_setsflg == 2);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
while (true) {
ModalDialog(filterProc, &itemHit);
switch(itemHit) {
case 1: /* OK */
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, cf_hostname);
p2cstr(cf_hostname);
GetDItem(dlgptr, 7, >ype, &gitem, &gbox);
GetIText(gitem, cf_wtitle);
p2cstr(cf_wtitle);
break;
case 2: /* set defaults */
if (cf_setsflg == 2) tcpdflthost(dflthostname);
else if (cf_setsflg == 1) serdflthost(dflthostname);
else sadflthost(dflthostname);
savedefault = 0;
sethostcf(dlgptr, dflthostname, "", savedefault);
i = strlen(dflthostname);
SelIText(dlgptr, 5, i, i);
break;
case 8:
savedefault ^= 1;
sethostcf(dlgptr, 0, 0, savedefault);
break;
default:
break;
}
if ((itemHit == 1) || (itemHit == 3)) break;
}
if ((itemHit == 1) && savedefault) { /* store new default host name */
updhostrsc(cf_hostname);
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
void sethostcf(DialogPtr dlgptr, unsigned char *hname,
unsigned char *wtitle, char sdefault)
{
short gtype;
Handle gitem;
Rect gbox;
if (hname != 0) {
GetDItem(dlgptr, 5, >ype, &gitem, &gbox); /* hostname */
c2pstr(hname);
SetIText(gitem, hname);
p2cstr(hname);
}
if (wtitle != 0) {
GetDItem(dlgptr, 7, >ype, &gitem, &gbox); /* window title */
c2pstr(wtitle);
SetIText(gitem, wtitle);
p2cstr(wtitle);
}
GetDItem(dlgptr, 8, >ype, &gitem, &gbox); /* save default */
SetCtlValue((ControlHandle)gitem, sdefault);
}
void specdlg(void)
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short * itemHitPtr;
short itemHit, oldHit;
short gtype;
Handle gitem;
Rect gbox;
unsigned char s[256];
unsigned char d_hostname[256];
char d_setsflg, d_dblevel;
unsigned char d_timeout, d_retries;
short i;
int r;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(258, dStorage, behind);
ctrwindow(dlgptr);
/* copy current values of items */
memcpy(d_hostname, cf_hostname, 256);
d_setsflg = cf_setsflg;
d_dblevel = cf_dblevel;
d_timeout = cf_timeout;
d_retries = cf_retries;
/* show current values of items */
setspec(dlgptr, d_hostname, d_setsflg, d_timeout, d_retries,
d_dblevel);
/* select host name text */
SelIText(dlgptr, 5, 0, 32767);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
oldHit = 0;
while (1) {
ModalDialog(filterProc, itemHitPtr);
if ((oldHit > 0) && (oldHit != itemHit))
switch(oldHit) {
case 5: /* hostname */
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, s);
p2cstr(s);
if (d_setsflg == 2) {
if (strlen(s) > 255) s[255] = 0;
}
else if (strlen(s) > 31) s[31] = 0;
i = 0;
while (s[i] != 0) {
d_hostname[i] = s[i];
i++;
}
d_hostname[i] = 0;
c2pstr(d_hostname);
SetIText(gitem, d_hostname);
p2cstr(d_hostname);
break;
case 11: /* timeout */
case 13: /* retries */
case 15: /* debug level */
GetDItem(dlgptr, oldHit, >ype, &gitem, &gbox);
GetIText(gitem, s);
p2cstr(s);
if (sscanf(s, "%d", &r) != 1) r = 0;
if (oldHit == 11) {
if ((r > 0) && (r <= 10)) d_timeout = r;
sprintf(s, "%2d", d_timeout);
}
else if (oldHit == 13) {
if ((r > 0) && (r <= 99)) d_retries = r;
sprintf(s, "%2d", d_retries);
}
else {
if ((r >= 0) && (r <= 127)) d_dblevel = r;
sprintf(s, "%2d", d_dblevel);
}
c2pstr(s);
SetIText(gitem, s);
break;
default:
break;
}
oldHit = itemHit;
switch(itemHit) {
case 1: /* OK */
memcpy(cf_hostname, d_hostname, 256);
cf_setsflg = d_setsflg;
cf_dblevel = d_dblevel; /* copy new settings */
cf_timeout = d_timeout;
cf_retries = d_retries;
break;
case 2: /* set defaults */
d_setsflg = ds.setsflg;
if (d_setsflg == 2) tcpdflthost(d_hostname);
else if (d_setsflg == 1) serdflthost(d_hostname);
else sadflthost(d_hostname);
d_dblevel = ds.dblevel;
d_timeout = ds.timeout;
d_retries = ds.retries;
setspec(dlgptr, d_hostname, d_setsflg,
d_timeout, d_retries, d_dblevel);
i = strlen(d_hostname);
SelIText(dlgptr, 5, i, i);
break;
case 6: /* Make Default for host name */
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, s);
p2cstr(s);
updhostrsc(s);
break;
case 7: /* AppleTalk */
case 8: /* Serial */
case 9: /* TCP/IP */
d_setsflg = itemHit - 7;
GetDItem(dlgptr, 7, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, d_setsflg == 0);
GetDItem(dlgptr, 8, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, d_setsflg == 1);
GetDItem(dlgptr, 9, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, d_setsflg == 2);
break;
default: break;
}
if ((itemHit == 1) || (itemHit == 3)) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
void setspec(DialogPtr dlgptr, unsigned char *hname, char sflg,
unsigned char timeout, unsigned char retries,
char debug)
{
short gtype;
Handle gitem;
Rect gbox;
unsigned char s[40];
GetDItem(dlgptr, 5, >ype, &gitem, &gbox); /* hostname */
c2pstr(hname);
SetIText(gitem, hname);
p2cstr(hname);
GetDItem(dlgptr, 7, >ype, &gitem, &gbox); /* Standalone */
SetCtlValue((ControlHandle)gitem, sflg == 0);
GetDItem(dlgptr, 8, >ype, &gitem, &gbox); /* Serial */
SetCtlValue((ControlHandle)gitem, sflg == 1);
GetDItem(dlgptr, 9, >ype, &gitem, &gbox); /* TCP/IP */
SetCtlValue((ControlHandle)gitem, sflg == 2);
GetDItem(dlgptr, 11, >ype, &gitem, &gbox); /* timeout */
sprintf(s, "%2d", timeout);
c2pstr(s);
SetIText(gitem, s);
GetDItem(dlgptr, 13, >ype, &gitem, &gbox); /* retries */
sprintf(s, "%2d", retries);
c2pstr(s);
SetIText(gitem, s);
GetDItem(dlgptr, 15, >ype, &gitem, &gbox); /* debug level */
sprintf(s, "%2d", debug);
c2pstr(s);
SetIText(gitem, s);
}
OSErr hostdlg(unsigned char *s)
{ /* "s" assumed to be 256 bytes */
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short itemHit, oldHit;
short gtype;
Handle gitem;
Rect gbox;
unsigned char d_hostname[256];
OSErr rc;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(282, dStorage, behind);
ctrwindow(dlgptr);
/* copy current values of items */
memcpy(d_hostname, s, 256);
/* define host name text */
GetDItem(dlgptr, 4, >ype, &gitem, &gbox); /* hostname */
c2pstr(d_hostname);
SetIText(gitem, d_hostname);
p2cstr(d_hostname);
SelIText(dlgptr, 4, 0, 32767);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
oldHit = 0;
rc = 1; /* assume "cancel" */
while (1) {
ModalDialog(filterProc, &itemHit);
if ((oldHit > 0) && (oldHit != itemHit))
switch(oldHit) {
case 4: /* hostname */
GetDItem(dlgptr, 4, >ype, &gitem, &gbox);
GetIText(gitem, d_hostname);
p2cstr(d_hostname);
if (strlen(d_hostname) > 255) {
d_hostname[255] = 0;
}
c2pstr(d_hostname);
SetIText(gitem, d_hostname);
p2cstr(d_hostname);
break;
default:
break;
}
oldHit = itemHit;
switch(itemHit) {
case 1: /* OK */
strcpy(s, d_hostname);
rc = 0;
break;
default: break;
}
if ((itemHit == 1) || (itemHit == 2)) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
return(rc);
}
void featdlg(cnr *cp)
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short itemHit;
char d_insreset, d_impnull, d_repnull, d_digitpfk, d_ext3270, d_std_brack;
static unsigned char * ScrDmpEnb = (unsigned char *)0x2f8;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(260, dStorage, behind);
ctrwindow(dlgptr);
/* copy current values of items */
d_insreset = cp->cs.insreset;
d_impnull = cp->cs.impnull;
d_repnull = cp->cs.repnull;
d_digitpfk = cp->cs.digitpfk;
d_ext3270 = cp->cs.ext3270;
d_std_brack = cp->cs.std_brack;
/* show current values of items */
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk, d_ext3270,
d_std_brack);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
while (1) {
ModalDialog(filterProc, &itemHit);
switch(itemHit) {
case 1: /* OK */
cp->cs.insreset = d_insreset;
cp->cs.impnull = d_impnull;
cp->cs.repnull = d_repnull;
cp->cs.digitpfk = d_digitpfk;
cp->cs.ext3270 = d_ext3270;
cp->cs.std_brack = d_std_brack;
cp->fixbracket = cp->cs.std_brack && (!cp->aplmode) &&
(cp->stdfont != ALAFONT);
if (cp->cs.digitpfk) (*ScrDmpEnb) = 0;
else (*ScrDmpEnb) = ScrDmpSav;
break;
case 3: /* yes */
case 4: /* no */
d_insreset = 4 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 6: /* yes */
case 7: /* no */
d_impnull = 7 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 9: /* yes */
case 10: /* no */
d_repnull = 10 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 12: /* yes */
case 13: /* no */
d_digitpfk = 13 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 15: /* yes */
case 16: /* no */
d_ext3270 = 16 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 18: /* yes */
case 19: /* no */
d_std_brack = 19 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 20: /* set defaults */
d_insreset = d_impnull = d_repnull = d_digitpfk = d_ext3270 =
d_std_brack = 1;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
default: break;
}
if ((itemHit == 1) || (itemHit == 21)) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
void setfeat(DialogPtr dlgptr, char d_insreset, char d_impnull,
char d_repnull, char d_digitpfk, char d_ext3270,
char d_std_brack)
{
setit(3, dlgptr, d_insreset != 0); /* yes */
setit(4, dlgptr, d_insreset == 0); /* no */
setit(6, dlgptr, d_impnull != 0); /* yes */
setit(7, dlgptr, d_impnull == 0); /* no */
setit(9, dlgptr, d_repnull != 0); /* yes */
setit(10, dlgptr, d_repnull == 0); /* no */
setit(12, dlgptr, d_digitpfk != 0); /* yes */
setit(13, dlgptr, d_digitpfk == 0); /* no */
setit(15, dlgptr, d_ext3270 != 0); /* yes */
setit(16, dlgptr, d_ext3270 == 0); /* no */
setit(18, dlgptr, d_std_brack != 0); /* yes */
setit(19, dlgptr, d_std_brack == 0); /* no */
}
short savedlg(char update, cnr *cp)
{
#pragma unused(cp)
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short * itemHitPtr;
short itemHit, dlgnum;
dStorage = 0;
behind = (WindowPtr)-1;
if (update) dlgnum = 290;
else dlgnum = 261;
dlgptr = GetNewDialog(dlgnum, dStorage, behind);
ctrwindow(dlgptr);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
while (1) {
ModalDialog(filterProc, itemHitPtr);
if (itemHit == 1) break;
if (itemHit == 2) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
return(2 - itemHit);
}
void clickdlg(cnr *cp)
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short gtype;
Handle gitem;
Rect mybox;
short itemHit;
short * itemHitPtr;
short savepf, temppf;
GrafPtr gp;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(266, dStorage, behind);
ctrwindow(dlgptr);
/* define routine to draw user item */
GetDItem(dlgptr, 4, >ype, &gitem, &mybox);
attnmousepf = cp->cs.mousepf;
SetDItem(dlgptr, 4, gtype, (Handle)attndlg, &mybox);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
itemHit = 99;
itemHitPtr = &itemHit;
filterProc = DlgFilter;
savepf = cp->cs.mousepf;
while ((itemHit != 1) && (itemHit != 3)) {
attnmousepf = cp->cs.mousepf;
ModalDialog(filterProc, itemHitPtr);
switch(itemHit) {
case 1: /* OK */
break;
case 2: /* Set Default */
mousehit.v = mybox.top + 85;
mousehit.h = mybox.left + 279;
GetPort(&gp);
SetPort(dlgptr);
LocalToGlobal(&mousehit);
SetPort(gp);
case 4: /* Function Keys */
GetPort(&gp);
SetPort(dlgptr);
GlobalToLocal(&mousehit);
/* memcpy(&lpoint, &mousehit, 4); struct -> long */
temppf = cp->cs.mousepf;
attnmenu(mChooseMsg, (MenuHandle)0, &mybox,
mousehit, &(cp->cs.mousepf));
if (cp->cs.mousepf == 0) {
cp->cs.mousepf = temppf;
attnmenu(mChooseMsg, (MenuHandle)0, &mybox,
mousehit, &(cp->cs.mousepf));
cp->cs.mousepf = temppf;
}
SetPort(gp);
break;
case 3: /* Cancel */
cp->cs.mousepf = savepf;
break;
default:
break;
}
}
DisposDialog(dlgptr);
}
void stgalert(unsigned char *kind, unsigned char *routine,
long amount)
{
unsigned char message[80];
pascal Boolean (*filterProc) ();
filterProc = DlgFilter;
sprintf(message, "%s attempt to allocate %ld bytes for %s failed.",
routine, amount, kind);
dbdlg(message);
StopAlert(263, filterProc);
}
void seterr(void)
{
pascal Boolean (*filterProc) ();
c2pstr(setmsg1);
c2pstr(setmsg2);
c2pstr(setmsg3);
ParamText(setmsg1, setmsg2, setmsg3, "\p");
p2cstr(setmsg1);
p2cstr(setmsg2);
p2cstr(setmsg3);
filterProc = DlgFilter;
if (strlen(setmsg3) == 0)
{
StopAlert(288, filterProc);
}
else {
StopAlert(289, filterProc);
}
ParamText("\p", "\p", "\p", "\p");
}
/* code taken from dbprint */
void dbdlg(unsigned char *string)
{
DialogRecord dStorage;
Rect boundry;
char visible = 0, goAway = 0;
WindowPtr behind = (WindowPtr)-1;
struct {
short numitems;
/* Button stuff */
long Bhandle;
short Btop,
Bleft,
Bbottom,
Bright;
char Btype;
char Blen;
unsigned char Btext[2];
/* Text item */
long Thandle;
short Ttop,
Tleft,
Tbottom,
Tright;
char Ttype;
char Tlen;
unsigned char Ttext[255];
} DStruct;
DialogPtr theBox;
short dummy, l;
Size DSsize;
Handle itemlist;
pascal Boolean (*filterProc) ();
OSErr rc;
if (cf_dblevel == 0) return;
if (mf_bgrnd && notifyavail) {
c2pstr(string);
rc = notifymsg(string);
p2cstr(string);
if (rc == noErr) return;
}
filterProc = DlgFilter;
DStruct.numitems = 1;
DStruct.Thandle = 0;
DStruct.Ttop = 50;
DStruct.Tleft = 30;
DStruct.Tbottom = 100;
DStruct.Tright = 260;
DStruct.Ttype = statText + itemDisable;
l = strlen(string);
if (l > 254) l = 254;
strcpy(DStruct.Ttext, string);
if (l%2) {
strcat(DStruct.Ttext, " ");
l++;
}
DStruct.Tlen = l;
DStruct.Bhandle = 0;
DStruct.Btop = 10;
DStruct.Bleft = 160;
DStruct.Bbottom = 30;
DStruct.Bright = 240;
DStruct.Btype = ctrlItem + btnCtrl;
DStruct.Blen = 2;
DStruct.Btext[0] = 'O';
DStruct.Btext[1] = 'K';
boundry.top = 120;
boundry.left = 120;
boundry.bottom = 240;
boundry.right = 400;
DSsize = sizeof(DStruct) - 255 + l;
itemlist = NewHandle(DSsize);
memcpy(*itemlist, &DStruct, (short) DSsize);
arrowcursor();
theBox = NewDialog(&dStorage, &boundry, "\pDebug Text",
visible, dBoxProc, behind, goAway, 0L, itemlist);
ctrwindow(theBox);
ShowWindow(theBox);
/* highlight the default item */
framedflt(theBox);
ModalDialog(filterProc, &dummy);
DisposDialog(theBox);
}
void note_err(short code, cnr *cp)
{
pascal Boolean (*filterProc) ();
Handle errtext;
static char nullstr[1] = {0};
if (cp != 0) {
if (cp->apiopen) {
if (cp->apinoalert) return;
}
}
errtext = GetResource('STR ', code);
if (errtext == 0) return;
if (mf_bgrnd && notifyavail) {
if (notifymsg(*errtext) == noErr) return;
}
ParamText(*errtext, nullstr, nullstr, nullstr);
filterProc = DlgFilter;
arrowcursor();
if (code == mapalrt) {
NoteAlert(278, filterProc); /* appears only once */
}
else {
NoteAlert(281, filterProc); /* appears always */
}
ParamText(nullstr, nullstr, nullstr, nullstr);
}
void stoperr(short code, cnr *cp)
{
pascal Boolean (*filterProc) ();
Handle errtext;
static char nullstr[1] = {0};
if (cp != 0) {
if ((cp->apiopen) && (cp->apinoalert)) {
return;
}
}
errtext = GetResource('STR ', code);
if (errtext == 0) return;
if (mf_bgrnd && notifyavail) {
if (notifymsg(*errtext) == noErr) return;
}
ParamText(*errtext, nullstr, nullstr, nullstr);
filterProc = DlgFilter;
arrowcursor();
StopAlert(264, filterProc);
ParamText(nullstr, nullstr, nullstr, nullstr);
}
void stopterr(unsigned char *text, cnr *cp)
{
pascal Boolean (*filterProc) ();
static char nullstr[1] = {0};
OSErr rc;
if (cp != 0) {
if (cp->apiopen) {
if (cp->apinoalert) return;
}
}
if (mf_bgrnd && notifyavail) {
c2pstr(text);
rc = notifymsg(text);
p2cstr(text);
if (rc == noErr) return;
}
c2pstr(text);
ParamText(text, nullstr, nullstr, nullstr);
p2cstr(text);
filterProc = DlgFilter;
arrowcursor();
StopAlert(264, filterProc);
ParamText(nullstr, nullstr, nullstr, nullstr);
}
OSErr notifymsg(unsigned char *msg)
{ /* msg is Pascal string */
short i, n;
nmrmessage *nmp;
OSErr rc;
n = -1;
for (i=0; i < NMRNUM; i++) {
if (myNMR[i]->qelem.nmRefCon == 0) {
n = i;
break;
}
}
if (n == -1) return(1);
nmp = myNMR[n];
/* copy message text to message structure */
memcpy(nmp->msg, "\ptn3270: ", 9);
i = msg[0];
if (i > 247) i = 247;
memcpy(nmp->msg+9, msg+1, i);
nmp->msg[0] += i;
/* define notification manager request */
memset(&nmp->qelem, 0, sizeof(NMRec));
nmp->qelem.qType = nmType;
nmp->qelem.nmSound = (Handle)-1;
nmp->qelem.nmStr = nmp->msg;
nmp->qelem.nmResp = (NMProcPtr)nmproc; /* calls nmend */
nmp->qelem.nmRefCon = GetA5();
rc = NMInstall(&nmp->qelem);
if (rc != noErr) nmp->qelem.nmRefCon = 0;
return(rc);
}
void nmend(NMRecPtr nmReqPtr)
{
NMRemove(nmReqPtr); /* dequeue request */
nmReqPtr->nmRefCon = 0; /* mark as available */
}
pascal Boolean DlgFilter(DialogPtr dlg, EventRecord *eventptr,
short *itemptr)
{
#pragma unused(dlg)
unsigned char i;
if (havetcp) myStask();
switch(eventptr->what) {
case mouseDown:
mousehit = eventptr->where;
return(0);
case keyDown:
i = (eventptr->message & 0x7f); /* ascii code */
if ((i == 0x03) || (i == 0x0d)) {
(*itemptr) = 1;
return(-1);
}
default:
return(0);
}
}
pascal Boolean fmtDlgFilter(DialogPtr dlg, EventRecord *eventptr,
short *itemptr)
{
short i;
GrafPtr gp;
Point mouseLoc;
short gtype;
Handle gitem;
Rect gbox, toprect, bottomrect;
if (havetcp) myStask();
switch(eventptr->what) {
case mouseDown:
case mouseUp:
GetPort(&gp);
SetPort(dlg);
mouseLoc = eventptr->where;
GlobalToLocal(&mouseLoc);
SetPort(gp);
GetDItem(dlg, 19, >ype, &gitem, &gbox);
if (PtInRect(mouseLoc, &gbox)) {
if ((eventptr->what) == mouseUp) {
(*itemptr) = 19;
return(-1);
}
toprect = bottomrect = gbox;
toprect.bottom = bottomrect.top =
(gbox.top + gbox.bottom) / 2;
GetDItem(dlg, 18, >ype, &gitem, &gbox);
arrowinc(dlg, 18, gitem, &toprect, &bottomrect, 24, fmtmaxrows);
(*itemptr) = 17;
return(-1);
}
GetDItem(dlg, 22, >ype, &gitem, &gbox);
if (PtInRect(mouseLoc, &gbox)) {
if ((eventptr->what) == mouseUp) {
(*itemptr) = 22;
return(-1);
}
toprect = bottomrect = gbox;
toprect.bottom = bottomrect.top =
(gbox.top + gbox.bottom) / 2;
GetDItem(dlg, 21, >ype, &gitem, &gbox);
arrowinc(dlg, 21, gitem, &toprect, &bottomrect, 80, fmtmaxcols);
(*itemptr) = 20;
return(-1);
}
return(0);
case keyDown:
i = (eventptr->message & 0x7f); /* ascii code */
if ((i == 0x03) || (i == 0x0d)) {
(*itemptr) = 1;
return(-1);
}
default:
return(0);
}
}
void arrowinc(DialogPtr dlg, short item, Handle gitem, Rect *increct,
Rect *decrect, short min, short max)
{
unsigned char result[256];
register short num;
static unsigned long * Ticks = (unsigned long *)0x16a;
unsigned long ticklim;
GrafPtr gp;
Point mouseLoc;
/* get initial value of item, and make valid if necessary */
GetIText(gitem, result);
p2cstr(result);
num = atoi(result);
if (num < min) num = min;
if (num > max) num = max;
sprintf(result, "%d", num);
c2pstr(result);
SetIText(gitem, result);
if (item == (((DialogPeek)dlg)->editField)+1) {
SelIText(dlg, item, 0, 32767);
}
/* change value while mouse is down and in rectangle */
ticklim = (*Ticks);
while (StillDown()) {
if ((*Ticks) >= ticklim) {
ticklim = (*Ticks) + 7;
GetPort(&gp);
SetPort(dlg);
GetMouse(&mouseLoc);
SetPort(gp);
if (PtInRect(mouseLoc, increct)) {
if (num == max) continue;
num++;
}
else if (PtInRect(mouseLoc, decrect)) {
if (num == min) continue;
num--;
}
else continue;
sprintf(result, "%d", num);
c2pstr(result);
SetIText(gitem, result);
if (item == (((DialogPeek)dlg)->editField)+1) {
SelIText(dlg, item, 0, 32767);
}
}
}
}
pascal Boolean ListDlgFilter(DialogPtr dlg, EventRecord *eventptr,
short *itemptr)
{
unsigned char i;
Rect itemRect;
short itemType;
Handle itemHandle;
Point where;
ListHandle list;
GrafPtr gp;
if (havetcp) myStask();
switch(eventptr->what) {
case mouseDown:
GetPort(&gp);
SetPort(dlg);
GetDItem(dlg, 14, &itemType, &itemHandle, &itemRect);
where = eventptr->where;
GlobalToLocal(&where);
if (PtInRect(where, &itemRect)) {
*itemptr = 14;
itemRect.right -= 15;
if (PtInRect(where, &itemRect)) {
*itemptr = 16;
}
list = (ListHandle)((DialogPeek)dlg)->window.refCon;
LClick(where, eventptr->modifiers, list);
SetPort(gp);
return(-1);
}
else {
SetPort(gp);
return(0);
}
break;
case keyDown:
i = (eventptr->message & 0x7f); /* ascii code */
if ((i == 0x03) || (i == 0x0d)) {
(*itemptr) = 1;
return(-1);
}
default:
return(0);
}
}
void xfdlg(short code, unsigned char *msg1, unsigned char *msg2,
unsigned char *msg3, unsigned char *msg4, cnr *cp)
{
Ptr dStorage;
WindowPtr behind;
GrafPtr temp;
struct WStateData * wsptr;
struct WindowRecord * xtemp;
Point p;
switch (code) {
case 0:
dStorage = (Ptr)&(cp->dlgrec);
behind = (WindowPtr)-1;
cp->xdlgptr = GetNewDialog(267, dStorage, behind);
ctrwindow(cp->xdlgptr);
ShowWindow(cp->xdlgptr);
xtemp = (struct WindowRecord *)cp->xdlgptr;
if (xtemp->dataHandle != 0) {
wsptr = (struct WStateData *)*(xtemp->dataHandle);
wsptr->stdState = (cp->xdlgptr)->portRect;
GetPort(&temp);
SetPort(cp->xdlgptr);
p.h = wsptr->stdState.left;
p.v = wsptr->stdState.top;
LocalToGlobal(&p);
wsptr->stdState.left = p.h;
wsptr->stdState.top = p.v;
p.h = wsptr->stdState.right;
p.v = wsptr->stdState.bottom;
LocalToGlobal(&p);
wsptr->stdState.right = p.h;
wsptr->stdState.bottom = p.v;
SetPort(temp);
}
cp->xdlg = 1;
cp->msg1flg = 0;
return;
case 1:
if (cp->msg1flg == 0) {
cp->msg1flg = 1;
settext(cp->xdlgptr, 1, msg1);
}
settext(cp->xdlgptr, 3, msg2);
settext(cp->xdlgptr, 5, msg3);
settext(cp->xdlgptr, 7, msg4);
xfGrowIcon(cp);
return;
default:
if (cp->xdlg == 0) return;
cp->xdlg = 0;
DisposDialog(cp->xdlgptr);
return;
}
}
void cf_fmtdlg(void)
{
register DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short itemHit, lasthit;
short * itemHitPtr;
short gtype;
Handle gitem;
Rect gbox;
short dfltptsize, altptsize;
short altrows, altcols;
short custrows, custcols;
char windmax, changed, customflag, skipflag, savewpos;
unsigned char result[256], newnum[10];
short i;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(269, dStorage, behind);
ctrwindow(dlgptr);
filterProc = fmtDlgFilter;
itemHitPtr = &itemHit;
/* define routine to draw user items */
GetDItem(dlgptr, 19, >ype, &gitem, &gbox);
SetDItem(dlgptr, 19, gtype, (Handle)arrowproc, &gbox);
GetDItem(dlgptr, 22, >ype, &gitem, &gbox);
SetDItem(dlgptr, 22, gtype, (Handle)arrowproc, &gbox);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* copy current settings */
windmax = cf_windmax;
dfltptsize = cf_dfltptsize;
altptsize = cf_altptsize;
altrows = cf_altrows;
altcols = cf_altcols;
custrows = cf_custrows;
custcols = cf_custcols;
savewpos = cf_savewpos;
/* adjust settings to be valid */
adjfmt(&changed, &windmax, &dfltptsize, &altptsize, &altrows, &altcols);
if (altptsize == 9) {
fmtmaxrows = rowmax9;
fmtmaxcols = colmax9;
}
else {
fmtmaxrows = rowmax12;
fmtmaxcols = colmax12;
}
if (custrows < 24) custrows = 24;
if (custcols < 80) custcols = 80;
if (custrows > fmtmaxrows) custrows = fmtmaxrows;
if (custcols > fmtmaxcols) custcols = fmtmaxcols;
if (((altrows == 24) && (altcols == 80)) ||
((altrows == 32) && (altcols == 80)) ||
((altrows == 43) && (altcols == 80)) ||
((altrows == 27) && (altcols == 132))) {
customflag = 0;
}
else {
customflag = 1;
custrows = altrows;
custcols = altcols;
}
/* display initial settings */
setcffmt(dlgptr, 99, dfltptsize, windmax, altptsize,
altrows, altcols, customflag, custrows, custcols, savewpos);
itemHit = 99;
lasthit = 99;
while (1) {
ModalDialog(filterProc, itemHitPtr);
if (((lasthit == 18) && (itemHit != 18)) ||
((lasthit == 21) && (itemHit != 21)) ||
(itemHit == 19) || (itemHit == 22)) {
if ((lasthit == 18) || (itemHit == 19)) {
GetDItem(dlgptr, 18, >ype, &gitem, &gbox);
GetIText(gitem, result);
p2cstr(result);
custrows = atoi(result);
if (custrows < 24) custrows = 24;
if (custrows > fmtmaxrows) custrows = fmtmaxrows;
if (customflag) altrows = custrows;
}
else {
GetDItem(dlgptr, 21, >ype, &gitem, &gbox);
GetIText(gitem, result);
p2cstr(result);
custcols = atoi(result);
if (custcols < 80) custcols = 80;
if (custcols > fmtmaxcols) custcols = fmtmaxcols;
if (customflag) altcols = custcols;
}
}
if (itemHit < 3) break;
skipflag = 0;
switch (itemHit) {
case 3: dfltptsize = altptsize = 12;
windmax = ds.windmax;
altrows = 24;
altcols = 80;
adjfmt(&changed, &windmax, &dfltptsize,
&altptsize, &altrows, &altcols);
if (altptsize == 9) {
fmtmaxrows = rowmax9;
fmtmaxcols = colmax9;
}
else {
fmtmaxrows = rowmax12;
fmtmaxcols = colmax12;
}
customflag = 0;
custcols = fmtmaxcols;
custrows = fmtmaxrows;
savewpos = ds.savewpos;
break;
case 5: dfltptsize = 9;
break;
case 6: dfltptsize = 12;
break;
case 7: windmax ^= 1;
break;
case 8: savewpos ^= 1;
break;
case 10: altptsize = 9;
fmtmaxrows = rowmax9;
fmtmaxcols = colmax9;
break;
case 11: altptsize = 12;
fmtmaxrows = rowmax12;
fmtmaxcols = colmax12;
if (custrows > fmtmaxrows) custrows = fmtmaxrows;
if (custcols > fmtmaxcols) custcols = fmtmaxcols;
if (customflag) {
altrows = custrows;
altcols = custcols;
}
else {
if ((altrows > fmtmaxrows) || (altcols > fmtmaxcols)) {
altrows = 24;
altcols = 80;
}
}
break;
case 12: altrows = 24;
altcols = 80;
customflag = 0;
break;
case 13: altrows = 32;
altcols = 80;
customflag = 0;
break;
case 14: altrows = 43;
altcols = 80;
customflag = 0;
break;
case 15: altrows = 27;
altcols = 132;
customflag = 0;
break;
case 16: /* "custom" button and arrows */
case 19:
case 22:
altrows = custrows;
altcols = custcols;
customflag = 1;
break;
case 18:
case 21:
altrows = custrows; /* include selecting "custom" */
altcols = custcols;
customflag = 1;
GetDItem(dlgptr, itemHit, >ype, &gitem, &gbox);
GetIText(gitem, result);
p2cstr(result);
i = 0;
while (result[i] != 0) {
if ((result[i] != 0x20) && ((result[i] < 0x30) ||
(result[i] > 0x39))) {
SysBeep(1);
break;
}
i++;
}
i = atoi(result) % 1000;
if (i == 0) {
newnum[0] = 0;
}
else {
sprintf(newnum, "%d", i);
}
if (strcmp(result, newnum) != 0) {
c2pstr(newnum);
SetIText(gitem, newnum);
}
break;
default:
skipflag = 1;
break;
}
if (!skipflag) setcffmt(dlgptr, itemHit, dfltptsize, windmax, altptsize,
altrows, altcols, customflag, custrows, custcols, savewpos);
lasthit = itemHit;
}
DisposDialog(dlgptr);
if (itemHit == 1) {
cf_windmax = windmax;
cf_dfltptsize = dfltptsize;
cf_altptsize = altptsize;
cf_altrows = altrows;
cf_altcols = altcols;
cf_custrows = custrows;
cf_custcols = custcols;
cf_savewpos = savewpos;
}
}
setcffmt(DialogPtr dlgptr, short itemHit, short dfltptsize, char windmax,
short altptsize, short altrows, short altcols, char customflag,
short custrows, short custcols, char savewpos)
{
short crows, ccols;
short gtype;
Handle gitem;
Rect gbox;
unsigned char result[256], newnum[10];
if (itemHit == 18) {
GetDItem(dlgptr, 18, >ype, &gitem, &gbox);
GetIText(gitem, result);
p2cstr(result);
crows = atoi(result);
}
else crows = custrows;
if (itemHit == 21) {
GetDItem(dlgptr, 21, >ype, &gitem, &gbox);
GetIText(gitem, result);
p2cstr(result);
ccols = atoi(result);
}
else ccols = custcols;
setactive(1, dlgptr,
!(customflag && ((crows > fmtmaxrows) || (ccols > fmtmaxcols) ||
(crows < 24) || (ccols < 80))));
setit(5, dlgptr, dfltptsize == 9);
setit(6, dlgptr, dfltptsize == 12);
setactive(6, dlgptr, (rowmax12 >= 24) && (colmax12 >= 80));
setit(7, dlgptr, windmax);
setit(8, dlgptr, savewpos);
setit(10, dlgptr, altptsize == 9);
setit(11, dlgptr, altptsize == 12);
setactive(11, dlgptr, (rowmax12 >= 24) && (colmax12 >= 80));
setit(12, dlgptr, (altrows == 24) && (altcols == 80) && (!customflag));
setit(13, dlgptr, (altrows == 32) && (altcols == 80) && (!customflag));
setactive(13, dlgptr, fmtmaxrows >= 32);
setit(14, dlgptr, (altrows == 43) && (altcols == 80) && (!customflag));
setactive(14, dlgptr, fmtmaxrows >= 43);
setit(15, dlgptr, (altrows == 27) && (altcols == 132) && (!customflag));
setactive(15, dlgptr, (fmtmaxrows >= 27) && (fmtmaxcols >= 132));
setit(16, dlgptr, customflag);
if (itemHit != 18) {
GetDItem(dlgptr, 18, >ype, &gitem, &gbox);
GetIText(gitem, result);
p2cstr(result);
sprintf(newnum, "%d", custrows);
if (strcmp(result, newnum) != 0) {
c2pstr(newnum);
SetIText(gitem, newnum);
}
}
if (itemHit != 21) {
GetDItem(dlgptr, 21, >ype, &gitem, &gbox);
GetIText(gitem, result);
p2cstr(result);
sprintf(newnum, "%d", custcols);
if (strcmp(result, newnum) != 0) {
c2pstr(newnum);
SetIText(gitem, newnum);
}
}
}
pascal void arrowproc(WindowPtr dlgwindow, short item)
{
GrafPtr gp;
Rect myrect;
short dtype;
Handle ditem;
PolyHandle ph;
GetDItem(dlgwindow, item, &dtype, &ditem, &myrect);
GetPort(&gp);
SetPort(dlgwindow);
FrameRoundRect(&myrect, 8, 8);
ph = OpenPoly();
MoveTo(myrect.left+2, myrect.top+5);
LineTo(myrect.left+5, myrect.top+2);
LineTo(myrect.left+8, myrect.top+5);
LineTo(myrect.left+6, myrect.top+5);
LineTo(myrect.left+6, myrect.top+7);
LineTo(myrect.left+4, myrect.top+7);
LineTo(myrect.left+4, myrect.top+5);
LineTo(myrect.left+2, myrect.top+5);
ClosePoly();
FramePoly(ph);
PaintPoly(ph);
KillPoly(ph);
ph = OpenPoly();
MoveTo(myrect.left+2, myrect.top+12);
LineTo(myrect.left+5, myrect.top+15);
LineTo(myrect.left+8, myrect.top+12);
LineTo(myrect.left+6, myrect.top+12);
LineTo(myrect.left+6, myrect.top+10);
LineTo(myrect.left+4, myrect.top+10);
LineTo(myrect.left+4, myrect.top+12);
LineTo(myrect.left+2, myrect.top+12);
ClosePoly();
FramePoly(ph);
PaintPoly(ph);
KillPoly(ph);
SetPort(gp);
}
void fmtdlg(cnr *cp)
{
register DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short itemHit;
short gtype;
Handle gitem;
Rect gbox;
short dfltptsize, altptsize;
char windmax, savewpos, skipflag;
unsigned char result[256];
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(259, dStorage, behind);
ctrwindow(dlgptr);
filterProc = DlgFilter;
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* copy current settings */
windmax = cp->cs.windmax;
dfltptsize = cp->cs.dfltptsize;
altptsize = cp->cs.altptsize;
savewpos = cp->cs.savewpos;
/* disable 12-point buttons if not valid for screen size */
setactive(6, dlgptr, (rowmax12 >= 24) && (colmax12 >= 80));
setactive(11, dlgptr,
(rowmax12 >= cp->cs.altrows) && (colmax12 >= cp->cs.altcols));
/* set text for large screen format heading */
sprintf(result, "Large Screen Format (%d-by-%d):",
cp->cs.altrows, cp->cs.altcols);
c2pstr(result);
GetDItem(dlgptr, 9, >ype, &gitem, &gbox);
SetIText(gitem, result);
/* display initial settings */
setfmt(dlgptr, dfltptsize, windmax, altptsize, savewpos);
while (1) {
ModalDialog(filterProc, &itemHit);
if (itemHit < 3) break;
skipflag = 0;
switch (itemHit) {
case 3: if ((rowmax12 >= 24) && (colmax12 >= 80)) {
dfltptsize = 12;
}
else {
dfltptsize = 9;
}
if ((rowmax12 >= cp->cs.altrows) &&
(colmax12 >= cp->cs.altcols)) {
altptsize = 12;
}
else {
altptsize = 9;
}
windmax = ds.windmax;
savewpos = ds.savewpos;
break;
case 5: dfltptsize = 9;
break;
case 6: dfltptsize = 12;
break;
case 7: windmax ^= 1;
break;
case 8: savewpos ^= 1;
break;
case 10: altptsize = 9;
break;
case 11: altptsize = 12;
break;
default: skipflag = 1;
break;
}
if (!skipflag) setfmt(dlgptr, dfltptsize, windmax, altptsize, savewpos);
}
DisposDialog(dlgptr);
if (itemHit == 1) {
cp->cs.windmax = windmax;
cp->cs.dfltptsize = dfltptsize;
cp->cs.altptsize = altptsize;
cp->cs.savewpos = savewpos;
newmode(cp->cur_mode, 0, cp);
}
}
void setfmt(DialogPtr dlgptr, short dfltptsize, char windmax,
short altptsize, char savewpos)
{
setit(5, dlgptr, dfltptsize == 9);
setit(6, dlgptr, dfltptsize == 12);
setit(7, dlgptr, windmax);
setit(8, dlgptr, savewpos);
setit(10, dlgptr, altptsize == 9);
setit(11, dlgptr, altptsize == 12);
}
void miscdlg(cnr *cp)
{
register DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short itemHit;
short * itemHitPtr;
short gtype;
Handle gitem;
Rect gbox;
char newtime, newblock, newpos;
char newauto, newkeep;
GrafPtr gp;
ListHandle list;
Rect dataBounds;
Point cellSize, cell;
short i, sndcount, namelen;
char loadflag;
Handle reshandle, reshandle2;
short resid;
ResType restype;
unsigned char resname[256];
OSErr rc;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(271, dStorage, behind);
ctrwindow(dlgptr);
if (newroms) {
filterProc = ListDlgFilter;
}
else {
filterProc = DlgFilter;
}
itemHitPtr = &itemHit;
GetPort(&gp);
SetPort(dlgptr);
/* define routine to draw user items */
GetDItem(dlgptr, 13, >ype, &gitem, &gbox);
SetDItem(dlgptr, 13, gtype, (Handle)misctext, &gbox);
GetDItem(dlgptr, 14, >ype, &gitem, &gbox);
SetDItem(dlgptr, 14, gtype, (Handle)listproc, &gbox);
if (newroms) {
/* make room for scroll bar */
gbox.right -= 15;
/* create a list */
dataBounds.top = dataBounds.left = 0;
sndcount = CountResources('snd ');
dataBounds.bottom = sndcount + 1;
dataBounds.right = 1;
cellSize.h = cellSize.v = 0; /* use defaults */
list = LNew(&gbox, &dataBounds, cellSize, 0, (WindowPtr)dlgptr,
false, false, false, true);
/* allow the dialog manager routines to access the list record */
((DialogPeek)dlgptr)->window.refCon = (long)list;
/* allow only one selection at a time */
(*list)->selFlags = lOnlyOne;
}
else {
setactive(13, dlgptr, 0);
}
setit(4, dlgptr, cp->cs.stat_time==1);
setit(5, dlgptr, cp->cs.stat_time==2);
setit(6, dlgptr, cp->cs.stat_time==0);
setit(8, dlgptr, cp->cs.blockcurs==0);
setit(9, dlgptr, cp->cs.blockcurs);
setit(10, dlgptr, cp->cs.curpos);
setit(11, dlgptr, cp->cs.autoconn);
setit(12, dlgptr, cp->cs.keepwindow);
if (newroms) {
/* Initialize cell contents */
cell.h = cell.v = 0;
strcpy(resname, dssndname);
namelen = strlen(resname);
LSetCell(resname, namelen, cell, list);
if (strcmp(resname, cp->cssndname) == 0) LSetSelect(true, cell, list);
if (sndcount > 0) {
for (i=1; i <= sndcount; i++) {
cell.v++;
loadflag = 0;
SetResLoad(false);
reshandle = GetIndResource('snd ', i);
SetResLoad(true);
if (reshandle == 0) {
loadflag = 1;
reshandle = GetIndResource('snd ', i);
}
if (reshandle != 0) {
getsndinfo(reshandle, &resid, &restype, resname);
if (loadflag) ReleaseResource(reshandle);
namelen = strlen(resname);
LSetCell(resname, namelen, cell, list);
if (strcmp(resname, cp->cssndname) == 0)
LSetSelect(true, cell, list);
}
}
}
LAutoScroll(list);
LDoDraw(true, list);
}
newtime = cp->cs.stat_time;
newblock = cp->cs.blockcurs;
newpos = cp->cs.curpos;
newauto = cp->cs.autoconn;
newkeep = cp->cs.keepwindow;
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
itemHit = 99;
resname[0] = 0;
while (itemHit > 2) {
ModalDialog(filterProc, itemHitPtr);
switch (itemHit) {
case 4:
newtime = 1;
break;
case 5:
newtime = 2;
break;
case 6:
newtime = 0;
break;
case 8:
newblock = 0;
break;
case 9:
newblock = 1;
break;
case 10:
newpos ^= 1;
break;
case 11:
newauto ^= 1;
break;
case 12:
newkeep ^= 1;
break;
case 14:
case 16:
if (!newroms) {
beep(cp);
break;
}
resname[0] = 0;
cell.h = 0;
for (cell.v=0; cell.v < sndcount+1; cell.v++) {
if (LGetSelect(false, &cell, list)) {
namelen = 255;
LGetCell(resname, &namelen, cell, list);
resname[namelen] = 0;
break;
}
}
if ((strlen(resname) > 0) && (itemHit == 16)) {
if (strcmp(resname, dssndname) == 0) {
SysBeep(3);
}
else {
dlgplaysound(resname);
}
}
break;
default:
break;
}
if ((itemHit >= 4) && (itemHit <= 12)) {
setit(4, dlgptr, newtime==1);
setit(5, dlgptr, newtime==2);
setit(6, dlgptr, newtime==0);
setit(8, dlgptr, newblock==0);
setit(9, dlgptr, newblock);
setit(10, dlgptr, newpos);
setit(11, dlgptr, newauto);
setit(12, dlgptr, newkeep);
}
}
if (newroms) {
LDispose(list);
}
SetPort(gp);
DisposDialog(dlgptr);
if (itemHit == 1) {
if (cp->cs.stat_time != newtime) {
cp->cs.stat_time = newtime;
if (cp->myWindow != 0) newstat(cp);
}
if (cp->cs.blockcurs != newblock) {
cp->cs.blockcurs = newblock;
if (cp->myWindow != 0) newcur(cp);
}
if (cp->cs.curpos != newpos) {
cp->cs.curpos = newpos;
if (cp->myWindow != 0) newstat(cp);
}
cp->cs.autoconn = newauto;
cp->cs.keepwindow = newkeep;
if ((strcmp(cp->cssndname, resname) != 0) && (resname[0] != 0)) {
if (strcmp(resname, dssndname) == 0) {
if (sndactive) {
SndDisposeChannel(scp, true);
sndactive = 0;
}
if (cp->sndhandle != 0) DisposHandle(cp->sndhandle);
cp->sndhandle = 0;
strcpy(cp->cssndname, resname);
}
else {
reshandle = reshandle2 = getsndresource(resname);
if (reshandle != 0) {
rc = HandToHand(&reshandle2);
if (rc != noErr) {
ReleaseResource(reshandle);
stoperr(sdmemalrt, cp);
}
else {
getsndinfo(reshandle, &resid, &restype, resname);
ReleaseResource(reshandle);
if (sndactive) {
SndDisposeChannel(scp, true);
sndactive = 0;
}
if (cp->sndhandle != 0) DisposHandle(cp->sndhandle);
cp->sndhandle = reshandle2;
strcpy(cp->cssndname, resname);
}
}
}
}
}
}
void dlgplaysound(unsigned char *sndname)
{
Handle temph, temph2;
OSErr rc;
SndChannelPtr default_scp;
temph = temph2 = getsndresource(sndname);
if (temph == 0) return;
rc = HandToHand(&temph2);
ReleaseResource(temph);
if (rc == noErr) {
if (sndactive) {
SndDisposeChannel(scp, true);
sndactive = 0;
}
default_scp = 0;
rc = SndNewChannel(&default_scp, 0, 0L, 0L);
if (rc == noErr) {
SndPlay(default_scp, temph2, 0);
SndDisposeChannel(default_scp, 0);
}
DisposHandle(temph2);
}
}
pascal void listproc(DialogPtr dialog, short itemNo)
{
ListHandle list;
short itemType;
Handle itemHandle;
Rect itemRect;
GetDItem(dialog, itemNo, &itemType, &itemHandle, &itemRect);
if (newroms) {
list = (ListHandle)((DialogPeek)dialog)->window.refCon;
LUpdate(dialog->visRgn, list);
}
InsetRect(&itemRect, -1, -1);
if (!newroms) PenPat(&qd.gray);
FrameRect(&itemRect);
if (!newroms) PenPat(&qd.black);
}
pascal void misctext(WindowPtr wp, short inum)
{
short gtype;
Handle gitem;
Rect gbox;
GrafPort mp;
GrafPtr gp;
OSErr rc;
GetDItem(wp, inum, >ype, &gitem, &gbox);
rc = dlgnewmap(&mp, &gbox);
if (rc != 0) return;
GetPort(&gp);
SetPort(&mp);
MoveTo(gbox.left, gbox.top+12);
switch(inum) {
case 13:
DrawString("\pBeep Sound:");
break;
default:
break;
}
if (!newroms) {
PenPat(&qd.gray);
PenMode(patBic);
PaintRect(&gbox);
}
SetPort(wp);
CopyBits(&mp.portBits, &(wp->portBits), &gbox, &gbox, srcCopy, 0L);
SetPort(gp);
ClosePort(&mp);
DisposPtr(dlgmapptr);
}
OSErr dlgnewmap(GrafPtr wp, Rect *box)
{
BitMap dlgWriteMap;
Size mapsize;
GrafPtr gp;
dlgWriteMap.bounds = *box;
dlgWriteMap.rowBytes =
(dlgWriteMap.bounds.right - dlgWriteMap.bounds.left + 7) >> 3;
if (dlgWriteMap.rowBytes%2) dlgWriteMap.rowBytes++;
mapsize = dlgWriteMap.bounds.bottom - dlgWriteMap.bounds.top;
mapsize = mapsize * dlgWriteMap.rowBytes;
dlgmapptr = myNewPtr(mapsize, 0);
if (dlgmapptr == 0L) return(4);
dlgWriteMap.baseAddr = dlgmapptr;
wp->portRect = dlgWriteMap.bounds;
GetPort(&gp);
OpenPort(wp);
SetPortBits(&dlgWriteMap);
EraseRgn(wp->visRgn);
SetPort(gp);
}
void getsndinfo(Handle theResource, short *theID, ResType *theType,
unsigned char *name)
{
short i, namelength;
GetResInfo(theResource, theID, theType, name);
p2cstr(name);
namelength = strlen(name);
if (namelength > 0) {
for (i=0; i < namelength; i++) {
if (!isspace(name[i])) return;
}
}
/* if we get here, the name is null, or all white space */
/* generate a pseudo-name for the user and "getsndresource" */
sprintf(name, "(unnamed) #%d", *theID);
}
Handle getsndresource(unsigned char *name)
{
int resnum;
Handle result;
if (strlen(name) > 11) {
if (strncmp(name, "(unnamed) #", 11) == 0) {
if (1 == sscanf(name+11, "%d", &resnum)) {
return(GetResource('snd ', resnum));
}
}
}
c2pstr(name);
result = GetNamedResource('snd ', name);
p2cstr(name);
return(result);
}
void crsetdlg(cnr *cp)
{
DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short * itemHitPtr;
short itemHit, oldHit;
short gtype;
Handle gitem;
Rect gbox;
union {
OSType type;
unsigned char name[4];
} cr;
unsigned char crstr[5];
unsigned char instr[256];
char showok;
OSErr rc;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(283, dStorage, behind);
ctrwindow(dlgptr);
/* copy current value of creator */
cr.type = cp->cs.text_creator;
memcpy(crstr+1, cr.name, 4);
crstr[0] = 4;
/* define creator text */
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
SetIText(gitem, crstr);
SelIText(dlgptr, 5, 0, 32767);
/* handle file creator dialog */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
oldHit = 0;
showok = 1;
while (1) {
/* ModalDialog((ModalFilterProcPtr)filterProc, itemHitPtr); */
ModalDialog(filterProc, itemHitPtr);
if ((oldHit > 0) && (oldHit != itemHit))
switch(oldHit) {
case 5:
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, instr);
memcpy(crstr, instr, 5);
if (crstr[0] > 4) crstr[0] = 4;
while (crstr[0] < 4) {
crstr[crstr[0]+1] = ' ';
crstr[0]++;
}
break;
default:
break;
}
oldHit = itemHit;
switch(itemHit) {
case 1: /* OK */
memcpy(cr.name, crstr+1, 4);
cp->cs.text_creator = cr.type;
break;
case 2: /* get from app. */
rc = getapcr(&cr.type);
if (rc != noErr) {
framedflt(dlgptr);
break;
}
if (!showok) {
showok = 1;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
HiliteControl((ControlHandle)gitem, 0);
}
framedflt(dlgptr);
memcpy(crstr+1, cr.name, 4);
crstr[0] = 4;
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
SetIText(gitem, crstr);
SelIText(dlgptr, 5, 0, 32767);
break;
case 5:
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, instr);
if ((instr[0] < 1) || (instr[0] > 4)) {
if (showok) {
showok = 0;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
HiliteControl((ControlHandle)gitem, 255);
framedflt(dlgptr);
}
}
else {
if (!showok) {
showok = 1;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
HiliteControl((ControlHandle)gitem, 0);
framedflt(dlgptr);
}
}
break;
default: break;
}
if ((itemHit == 1) || (itemHit == 3)) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
void psdlg(cnr *cp)
{
DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short * itemHitPtr;
short itemHit;
short gtype;
Handle gitem;
Rect gbox;
char dlgps;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(284, dStorage, behind);
ctrwindow(dlgptr);
/* copy current value of flag and display it */
dlgps = cp->cs.simps;
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, dlgps);
/* handle PS simulation dialog */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
while (1) {
/* ModalDialog((ModalFilterProcPtr)filterProc, itemHitPtr); */
ModalDialog(filterProc, itemHitPtr);
switch(itemHit) {
case 1: /* OK */
cp->cs.simps = dlgps;
break;
case 2: /* Cancel */
break;
case 3: /* Check Box */
case 4:
dlgps ^= 1;
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, dlgps);
break;
default: break;
}
if (itemHit < 3) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
void conndlg(cnr *cp)
{
DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short itemHit;
short gtype;
Handle gitem;
Rect gbox;
unsigned char msgbuff[256];
unsigned char sname[256];
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(287, dStorage, behind);
ctrwindow(dlgptr);
/* set message text */
get_sessname(sname, cp);
if (cp->apiopen && (cp->connstate > 3)) {
strcpy(msgbuff, "\"");
msgappend(msgbuff, 256, sname);
msgappend(msgbuff, 256, "\" is a hidden API session connected ");
if (cp->connstate == 4) {
msgappend(msgbuff, 256, "in line mode.");
}
else {
msgappend(msgbuff, 256, "in 3270 mode.");
}
}
else {
switch(cp->connstate) {
case 0: /* should always have a window */
strcpy(msgbuff, "\"");
msgappend(msgbuff, 256, sname);
msgappend(msgbuff, 256, "\" is idle. Press return to open a new connection.");
break;
case 1: /* should always have a window */
strcpy(msgbuff, "\"");
msgappend(msgbuff, 256, sname);
msgappend(msgbuff, 256, "\" is an initial serial connection.");
break;
case 2:
strcpy(msgbuff, "Connection pending: awaiting name resolution for \"");
msgappend(msgbuff, 256, cp->hostonly);
msgappend(msgbuff, 256, "\".");
break;
case 3:
strcpy(msgbuff, "Connection pending: open in progress to \"");
msgappend(msgbuff, 256, cp->hostonly);
msgappend(msgbuff, 256, "\".");
break;
case 4: /* non-API should always have a window */
strcpy(msgbuff, "\"");
msgappend(msgbuff, 256, sname);
msgappend(msgbuff, 256, "\": connection established in line mode.");
break;
case 5: /* non-API should always have a window */
strcpy(msgbuff, "\"");
msgappend(msgbuff, 256, sname);
msgappend(msgbuff, 256, "\": connection established in 3270 mode.");
break;
default:
strcpy(msgbuff, "\"");
msgappend(msgbuff, 256, sname);
msgappend(msgbuff, 256, "\": unknown connection status.");
break;
}
}
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
c2pstr(msgbuff);
SetIText(gitem, msgbuff);
/* handle connection dialog */
filterProc = DlgFilter;
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* wait for user to exit */
ModalDialog(filterProc, &itemHit);
/* dispose of dialog */
DisposDialog(dlgptr);
/* close connection if requested */
if (itemHit == 2) {
if (!(cp->serflg && (cp->connstate <= 1))) {
closeresponse(closeUser, cp);
}
if (cp->serflg) serlgout(0, cp);
else if (cp->tcpflg) tcplgout(0, cp);
else salgout(0, cp);
}
}
void msgappend(unsigned char *buffer, short maxlength, unsigned char *new)
{
short currlen, newlen, availlen;
currlen = strlen(buffer);
availlen = maxlength - 1 - currlen;
if (availlen <= 0) return;
newlen = strlen(new);
if (newlen > availlen) newlen = availlen;
memcpy(buffer+currlen, new, newlen);
buffer[currlen + newlen] = 0;
}
OSErr getapcr(OSType *cr)
{
Point where;
FileFilterProcPtr fileFilter;
short numTypes;
SFTypeList typeList;
DlgHookProcPtr dlgHook;
SFReply reply;
FileParam fblk;
FileParam * _fblk;
OSErr rc;
where = sfgpoint;
fileFilter = 0;
dlgHook = 0;
numTypes = 1;
typeList[0] = 'APPL';
SFGetFile(where, "\p", fileFilter, numTypes,
typeList, dlgHook, &reply);
if (reply.good == 0) return(1);
_fblk = &fblk;
fblk.ioCompletion = 0;
fblk.ioNamePtr = (StringPtr)&reply.fName;
fblk.ioVRefNum = reply.vRefNum;
fblk.ioFVersNum = 0;
fblk.ioFDirIndex = 0;
rc = PBGetFInfo((ParmBlkPtr)_fblk, 0);
if (rc != noErr) return(rc);
(*cr) = fblk.ioFlFndrInfo.fdCreator;
return(noErr);
}
void cf_featdlg(void)
{
DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
pascal Boolean (*filterProc) ();
short * itemHitPtr;
short itemHit;
short dlgnum;
char newext, newgraphics, newcolor;
unsigned char cvtstring[256];
short gtype;
Handle gitem;
Rect gbox;
dStorage = 0;
behind = (WindowPtr)-1;
if (colormac) dlgnum = 285;
else dlgnum = 286;
dlgptr = GetNewDialog(dlgnum, dStorage, behind);
ctrwindow(dlgptr);
/* copy current values of flags and display them */
newext = cf_ext3270;
newgraphics = cf_nographics;
newcolor = cf_nocolor;
showcffeat(dlgptr, cvtstring, newext, newgraphics, newcolor);
/* show size for color text bitmap */
sprintf(cvtstring, "(requires %dK)", cfmapsize(0, newcolor==0));
c2pstr(cvtstring);
GetDItem(dlgptr, 8, >ype, &gitem, &gbox);
SetIText(gitem, cvtstring);
/* handle dialog */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
while (1) {
ModalDialog(filterProc, itemHitPtr);
switch(itemHit) {
case 1: /* OK */
cf_ext3270 = newext;
cf_nographics = newgraphics;
cf_nocolor = newcolor;
break;
case 2: /* Cancel */
break;
case 3: /* Set Defaults */
newext = ds.ext3270;
newgraphics = ds.nographics;
newcolor = ds.nocolor;
break;
case 4: /* Extended Datastream */
newext ^= 1;
break;
case 5: /* Suppress Graphics */
case 6:
newgraphics ^= 1;
break;
case 7: /* No Color */
case 8:
newcolor ^= 1;
break;
default:
break;
}
if (itemHit < 3) {
break;
}
else {
showcffeat(dlgptr, cvtstring, newext, newgraphics, newcolor);
}
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
showcffeat(DialogPtr dlgptr, unsigned char *cvs,
char ext, char graphics, char color)
{
short gtype;
Handle gitem;
Rect gbox;
setit(4, dlgptr, ext);
setit(5, dlgptr, graphics == 0);
sprintf(cvs, "(requires %dK)", cfmapsize(1, color==0));
c2pstr(cvs);
GetDItem(dlgptr, 6, >ype, &gitem, &gbox);
SetIText(gitem, cvs);
if (colormac) {
setit(7, dlgptr, color == 0);
}
}
void setit(short item, DialogPtr dlgptr, short code)
{
short gtype;
Handle gitem;
Rect gbox;
GetDItem(dlgptr, item, >ype, &gitem, &gbox);
SetCtlValue((ControlHandle)gitem, code);
}
void setactive(short item, DialogPtr dlgptr, char flag)
{
short gtype;
Handle gitem;
Rect gbox;
GetDItem(dlgptr, item, >ype, &gitem, &gbox);
if (flag) {
HiliteControl((ControlHandle)gitem, 0);
}
else {
HiliteControl((ControlHandle)gitem, 255);
}
if (item == 1) framedflt(dlgptr);
}
short wants_to_quit(cnr *cp)
/* if a session is in progress, verify user wants to quit */
{
pascal Boolean (*filterProc) ();
short item;
unsigned char sname[256];
unsigned char namebuff[256];
static char nullstr[1] = {0};
/* return TRUE if no connection established */
if (cp->connstate == 0) return(1);
filterProc = DlgFilter;
arrowcursor();
get_sessname(sname, cp);
if (strcmp(cp->sessname, cp->hostonly) == 0) {
c2pstr(sname);
ParamText(sname, nullstr, nullstr, nullstr);
}
else {
strcpy(namebuff, cp->hostonly);
if ((strlen(namebuff) + strlen(sname) + 3) < 256) {
strcat(namebuff, " (");
strcat(namebuff, sname);
strcat(namebuff, ")");
}
c2pstr(namebuff);
ParamText(namebuff, nullstr, nullstr, nullstr);
}
item = CautionAlert(279, filterProc);
ParamText(nullstr, nullstr, nullstr, nullstr);
if (item == 1) return(0); /* resume */
else return(1); /* end session */
}
void dFullAlt(short kShort, cnr *cp)
{
pascal Boolean (*filterProc) ();
unsigned char buf[10];
static char nullstr[1] = {0};
sprintf(buf, "%d", kShort);
c2pstr(cp->macFName+1);
c2pstr(buf);
c2pstr(cp->macVName+1);
ParamText(cp->macFName+1, buf, cp->macVName+1, nullstr);
p2cstr(cp->macFName+1);
p2cstr(buf);
p2cstr(cp->macVName+1);
filterProc = DlgFilter;
arrowcursor();
StopAlert(265, filterProc);
ParamText(nullstr, nullstr, nullstr, nullstr);
}
void settext(DialogPtr dlgptr, short item, unsigned char *text)
{
short gtype;
Handle gitem;
Rect gbox;
GetDItem(dlgptr, item, >ype, &gitem, &gbox);
c2pstr(text);
SetIText(gitem, text);
p2cstr(text);
}
void ctrwindow(GrafPtr wp)
{
short scrhsize, scrvsize;
short whsize, wvsize;
scrhsize = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
scrvsize = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;
whsize = wp->portRect.right-wp->portRect.left;
wvsize = wp->portRect.bottom - wp->portRect.top;
MoveWindow(wp, (scrhsize-whsize)/2, (scrvsize-wvsize)/3, 0);
}
void ctralrt(short a)
{ /* alert number */
Handle reshnd;
struct Rect * rptr;
short scrhsize, scrvsize;
short ahsize, avsize;
CouldAlert(a); /* read alert into memory and make unpurgeable */
reshnd = GetResource('ALRT', a);
if (reshnd == 0) return;
rptr = (struct Rect *)*reshnd;
scrhsize = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
scrvsize = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;
ahsize = rptr->right - rptr->left;
avsize = rptr->bottom - rptr->top;
rptr->top = (scrvsize-avsize)/3;
rptr->left = (scrhsize-ahsize)/2;
rptr->bottom = rptr->top + avsize;
rptr->right = rptr->left + ahsize;
}
void framedflt(DialogPtr dlgptr)
{
short gtype;
Handle gitem;
Rect gbox;
GrafPtr gp;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
GetPort(&gp);
SetPort(dlgptr);
OutlineButton((ControlHandle)gitem);
SetPort(gp);
}
void OutlineButton(ControlHandle button)
{
/* This routine provided by Macintosh DTS: */
/* Given any control handle, this will draw an outline around it. This is
used for the default button of a window. The extra nice feature here is
that I'll erase the outline for buttons that are inactive. Seems like
there should be a Toolbox call for getting a control's hilite state.
Since there isn't, I have to look into the control record myself. This
should be called for update and activate events.
The method for determining the oval diameters for the roundrect is a
little different than that recommended by Inside Mac. IM I-407 suggests
that you use a hardcoded (16,16) for the diameters. However, this only
looks good for small roundrects. For larger ones, the outline doesn't
follow the inner roundrect because the CDEF for simply buttons doesn't
use (16,16). Instead, it uses half the height of the button as the
diameter. By using this formula, too, our outlines look better. */
/* WARNING: This will set the current port to the control's window. */
Rect theRect;
PenState curPen;
short buttonOval;
if (button != 0) {
/* SetPort((*button)->contrlOwner); */ /* done by caller */
GetPenState(&curPen);
PenNormal();
theRect = (*button)->contrlRect;
InsetRect(&theRect, kButtonFrameInset, kButtonFrameInset);
buttonOval = (theRect.bottom - theRect.top) / 2;
if ((*button)->contrlHilite == 0) {
PenPat(&qd.black);
}
else {
PenPat(&qd.gray);
}
PenSize(kButtonFrameSize, kButtonFrameSize);
FrameRoundRect(&theRect, buttonOval, buttonOval);
SetPenState(&curPen);
}
}
void arrowcursor(void)
{
if (!dfltcurs) {
dfltcurs = 1;
SetCursor(normcurs);
}
}